<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Document</title>
</head>

<body>
JSAPI

<script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

<script>
    if (typeof WeixinJSBridge === "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', wechatJsApiConfig, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', wechatJsApiConfig);
            document.attachEvent('onWeixinJSBridgeReady', wechatJsApiConfig);
        }
    } else {
        wechatJsApiConfig();
    }

    function wechatJsApiConfig() {
        $.ajax({
            type: "post",
            url: "https://www.dcdev.net/lib/lib_of_back_end/v1.0.1/api/tencent/mp/mp_get_pay_jsapi_config.php",
            data: {params: JSON.stringify({"pid": '0000000000000000',"uid":"7cfd733cfa9a5ec7","body":"商品描述","total_fee":"0.01"})},
            success: function (res) {
                var obj = JSON.parse(res);
                if (obj.res === 1) {
                    var data = obj.data;
                    jsApiCall(
                        data.appId,
                        data.timeStamp,
                        data.nonceStr,
                        data.package,
                        data.signType,
                        data.sign
                    );
                } else {
                    alert(obj.desc);
                }
            }
        });
    }

    function jsApiCall(appid, timeStamp, nonceStr, packageData, signType, paySign) {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest', {
                "appId": "" + appid,     //公众号名称，由商户传入
                "timeStamp": "" + timeStamp,         //时间戳，自1970年以来的秒数
                "nonceStr": "" + nonceStr, //随机串
                "package": "" + packageData,
                "signType": "" + signType,         //微信签名方式：
                "paySign": "" + paySign //微信签名
            },
            // 支付后的返回在这里
            function (res) {
                alert("这里是支付状态的回调:" + res.err_code + ' ' + res.err_desc + ' ' + res.err_msg);
            }
        )
    }
</script>
</body>
</html>